import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-10-09
 * Time: 23:32
 */
public class TestH6 {
    public static void main(String[] args) {
        int[] num = {1,2,3,4,5,6,7};
        rotate(num,3);
        System.out.println(Arrays.toString(num));
    }
    public static void rotate(int[] nums, int k) {
        Deque<Integer> q = new LinkedList<>();
        int n = nums.length;
        for(int i = 0; i < n; i++) {
            q.offerFirst(nums[i]);
        }
        for(int i = 0; i < k; i++) {
            q.offerLast(q.pollFirst());
        }
        for(int i = 0; i < n; i++) {
            nums[i] = q.pollLast();
        }

    }
}
